/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.veterinarySystem.bl;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.its.dsw2.veterinarySystem.dao.DuenoMascotaDaoLocal;
import mx.its.dsw2.veterinarySystem.enumeraciones.TransactionStatus;
import mx.its.dsw2.veterinarySystem.modelo.DuenoMascota;

/**
 *
 * @author 100101
 */
@Stateless
public class DuenoMascotaBl implements DuenoMascotaBlLocal {
    @EJB
    private DuenoMascotaDaoLocal duenoMascotaDao;

    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public TransactionStatus register(DuenoMascota petOwner) {
        if(duenoMascotaDao.findDuplicity(petOwner)){
            return TransactionStatus.TRUNCATED;
        }else{
            duenoMascotaDao.create(petOwner);
            return TransactionStatus.REALIZED;
        }
        
    }

    @Override
    public TransactionStatus modify(DuenoMascota petOwner) {
        if(petOwner.getId()==null||duenoMascotaDao.find(petOwner.getId())==null){
            return TransactionStatus.TRUNCATED;
        }else{
            duenoMascotaDao.edit(petOwner);
        return TransactionStatus.REALIZED;
        }
    }

    @Override
    public TransactionStatus romove(DuenoMascota petOwner) {
        if(petOwner.getId()==null||duenoMascotaDao.find(petOwner.getId())==null){
        return TransactionStatus.TRUNCATED;
        }else{
            duenoMascotaDao.remove(petOwner);
            return TransactionStatus.REALIZED;
        }
    }

    @Override
    public List<DuenoMascota> getAll() {
        return duenoMascotaDao.findAll();
    }

    @Override
    public DuenoMascota getDuenoMascotaPorId(int idDuenoMascota) {
        return duenoMascotaDao.find(idDuenoMascota);
    }
    
    
    
    
    
    

}
